package com.ruoyi.web.controller.newTable;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TTeacher;
import com.ruoyi.system.service.ITTeacherService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专任教师数量及结构Controller
 * 
 * @author ruoyi
 * @date 2024-12-06
 */
@RestController
@RequestMapping("/system/teacher")
public class TTeacherController extends BaseController
{
    @Autowired
    private ITTeacherService tTeacherService;

    /**
     * 查询专任教师数量及结构列表
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:list')")
    @GetMapping("/list")
    public TableDataInfo list(TTeacher tTeacher)
    {
        startPage();
        List<TTeacher> list = tTeacherService.selectTTeacherList(tTeacher);
        return getDataTable(list);
    }

    /**
     * 导出专任教师数量及结构列表
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:export')")
    @Log(title = "专任教师数量及结构", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TTeacher tTeacher)
    {
        List<TTeacher> list = tTeacherService.selectTTeacherList(tTeacher);
        ExcelUtil<TTeacher> util = new ExcelUtil<TTeacher>(TTeacher.class);
        util.exportExcel(response, list, "专任教师数量及结构数据");
    }

    /**
     * 获取专任教师数量及结构详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tTeacherService.selectTTeacherById(id));
    }

    /**
     * 新增专任教师数量及结构
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:add')")
    @Log(title = "专任教师数量及结构", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTeacher tTeacher)
    {
        return toAjax(tTeacherService.insertTTeacher(tTeacher));
    }

    /**
     * 修改专任教师数量及结构
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:edit')")
    @Log(title = "专任教师数量及结构", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTeacher tTeacher)
    {
        return toAjax(tTeacherService.updateTTeacher(tTeacher));
    }

    /**
     * 删除专任教师数量及结构
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:remove')")
    @Log(title = "专任教师数量及结构", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tTeacherService.deleteTTeacherByIds(ids));
    }
}
